package com.sangharsh.core.algo;

import com.sangharsh.core.algo.base.Color;
import com.sangharsh.core.algo.base.Mode;

public class DirectedEdge {

	private Vertex source;
	private Vertex destination;
	private Color color;
	private Mode mode;

	private DirectedEdge(Vertex source, Vertex destination) {
		this.source = source;
		this.destination = destination;
	}
	public DirectedEdge(Vertex source, Vertex destination, Mode mode, Color color) {
		this(source, destination);
		this.mode = mode;
		this.color = color;
	}

	
	public Vertex getSource() {
		return source;
	}

	public Vertex getDestination() {
		return destination;
	}
	
	public String toString(){
		return destination.toString()+"["+color+"]";
	}
	
	public Color getColor() {
		return color;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((destination == null) ? 0 : destination.hashCode());
		result = prime * result + ((source == null) ? 0 : source.hashCode());
		result = prime * result + ((color == null) ? 0 : color.hashCode());
		return result;
	}

	public Mode getMode() {
		return mode;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		DirectedEdge other = (DirectedEdge) obj;
		if (destination == null) {
			if (other.destination != null)
				return false;
		} else if (!destination.equals(other.destination))
			return false;
		if (source == null) {
			if (other.source != null)
				return false;
		} else if (!source.equals(other.source))
			return false;
		if (color == null) {
			if (other.color != null)
				return false;
		} else if (!color.equals(other.color))
			return false;
		return true;
	}

}
